package com.ruoyi.common.flowable;

import cn.hutool.core.util.EnumUtil;

/**
 * 流程意见类型
 *
 * @author Xuan xuan
 * @date 2021/4/19
 */
public enum FlowComment {

    /**
     * 说明
     */
    NO_START("0", "未提交","warning"),
    NORMAL("1", "正常意见",""),
    REBACK("2", "退回意见","danger"),
    REJECT("3", "驳回意见","danger"),
    DELEGATE("4", "委派意见",""),
    ASSIGN("5", "转办意见",""),
    STOP("6", "终止流程","warning"),
    SUCCESS_FINISH("7", "审批完成","success");

    /**
     * 类型
     */
    private final String code;

    /**
     * 说明
     */
    private final String name;

    private final String type;


    FlowComment(String code, String name, String type) {
        this.code = code;
        this.name = name;
        this.type = type;
    }

    public String getType() {
        return type;
    }

    public String getCode() {
        return code;
    }

    public String getName() {
        return name;
    }

    public static String codeToName(String code){
        FlowComment f = EnumUtil.getBy(FlowComment::getCode, code);
        return f != null ? f.getName() : null;
    }

    public static String codeToType(String code){
        FlowComment f = EnumUtil.getBy(FlowComment::getCode, code);
        return f != null ? f.getType() : null;
    }

    public static String codeToNameForList(String code){
        if("1".equals(code)){
            return "审核中";
        }else{
            FlowComment f = EnumUtil.getBy(FlowComment::getCode, code);
            return f != null ? f.getName() : null;
        }
    }
}
